package Homework07;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Map;
import java.util.TreeMap;

public class Homework01 {
	public static void main(String[] args) throws IOException {
		BufferedReader br=new BufferedReader(new FileReader("sort.txt"));
		
		String line=null;
		
		Map<Integer, String> lines = new TreeMap<>();
		
		while((line=br.readLine())!=null){
			String[] str = line.split("\\.");
			 if (str.length >= 2){
				 lines.put(Integer.parseInt(str[0]), str[1]);
				}
			 }
			
		br.close();
		System.out.println(lines);
		
		FileWriter fw = new FileWriter("sort.txt");
		
		BufferedWriter out = new BufferedWriter(fw);
		for(int i=1;i<=lines.size();i++){
			out.write((i)+"."+lines.get(i));
			out.write("\n");
		}
		out.close();
	}

}
